/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package business;

import dal.TourDAL;
import java.util.ArrayList;
import java.util.List;
import model.Hotels;
import model.PackageTour;
import model.Locations;
import model.PackageTourDetails;
import model.PackageType;
import model.Places;
import model.TourBooking;

/**
 *
 * @author Nhang Con
 */
public class TourBusiness {

    private TourDAL tourDAL = new TourDAL();

    public boolean newTour(PackageTour ptour) {
        if (tourDAL.newPackageTour(ptour)) {

            return true;
        }
        return false;

    }

    public List<Hotels> getListHotel() {
        return tourDAL.listHotel();
    }

    public List<Locations> getListLocation() {
        return tourDAL.listLocation();

    }

    public List<PackageType> getListPType() {
        return tourDAL.listPackageType();

    }

    public List<Places> getListPlace() {
        return tourDAL.listPlace();
    }

    public List<PackageTour> getAllPackageTour() {
        return tourDAL.listAllPackageTour();
    }

    public List<Hotels> getListHotelByPlace(int placeid) {
        return tourDAL.listHotelByPlaceID(placeid);

    }

    public PackageTourDetails getPackageTourDetailsByID(int tourID) {
        return tourDAL.getPackageTourDetailsByID(tourID);
    }

    public boolean updatePTour(PackageTour pktour) {
        return tourDAL.updatePTour(pktour);
    }

    public PackageTour objectPkTour(int idtour) {

        return tourDAL.objectPackageTour(idtour);

    }

    public int getIndexTour() {
        return tourDAL.getRowInPKT();

    }

    public List<PackageTour> getListPKTByPage(int page) {

        return tourDAL.listPKTByPage(page);
    }

    public boolean createTourBooking(int customerID, int packageTourID, int quantity, float totalPrice) {
        return tourDAL.createTourBooking(customerID, packageTourID, quantity, totalPrice);
    }

    public List<PackageTour> getListSearch(String name) {
        return tourDAL.searchPackageTourByName(name);

    }

    public List<PackageTour> getListTourByType(int typeid) {
        return tourDAL.ListTourByType(typeid);

    }

    public int getRowInListPackageTourByTypeID(int typeID) {
        return tourDAL.listPackageTourByTypeID(typeID).size();
    }

    public List<PackageTour> listPackageTourByPage(int typeID, int pageID) {
        List<PackageTour> listTourByTypeID = tourDAL.listPackageTourByTypeID(typeID);
        List<PackageTour> listTourByPage = new ArrayList<PackageTour>();
        for (int i = (pageID - 1) * 3; i < (pageID * 3); i++) {
            try {
                listTourByPage.add(listTourByTypeID.get(i));
            } catch (IndexOutOfBoundsException e) {
                return listTourByPage;
            }
        }
        return listTourByPage;
    }

    public List<PackageTour> searchTourByPrice(float priceFrom, float priceTo) {
        return tourDAL.searchPackageTourByPrice(priceFrom, priceTo);
    }

    public TourBooking getTourBookingByID(int tourBookingID) {
        return tourDAL.getTourBookingByID(tourBookingID);
    }

    public List<PackageTour> listSearchTourState(int state) {
        return tourDAL.listTourByState(state);
    }

    public List<PackageTour> advanceSearchTour(String localName,float priceFrom, float priceTo) {
        return tourDAL.advanceSearchPackageTour(localName, priceFrom, priceTo);
    }
}
